package com.ntanh.mealplanner.main.custom_adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.ntanh.mealplanner.R;
import com.ntanh.mealplanner.main.objects.Recipe;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by duongdn on 08/03/2015.
 */
public class RecipeAdapter extends ArrayAdapter<Recipe> {

    private ArrayList<Recipe> items;
    private final Context context;
    public RecipeAdapter(Context context, int textViewResourceId, ArrayList<Recipe> items) {
        super(context, textViewResourceId, items);
        this.context = context;
        this.items = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            v = LayoutInflater.from(this.context).inflate(R.layout.recipe_item, parent, false);
        }
        Recipe o = items.get(position);
        TextView tt = (TextView) v.findViewById(R.id.recipe_item);
        tt.setText(o.getName());
        //Integer id = o.getId();
        //tt.setId(id);
        return v;
    }
}